package fluebot;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;

/**
 *
 * @author Aksel Kvitberg
 */
public class Compliment {

	ArrayList<String> compliments;
	Random random = new Random();

	public Compliment() {
		compliments = read("Compliments/compliments.txt");
	}

	public String compliment(String user, String user2) {
		String compliment = compliments.get(random.nextInt(compliments.size()));
		compliment = compliment.replaceAll("%s", user);
		compliment = compliment.replaceAll("%r", user2);
		return compliment;
	}

	private ArrayList<String> read(String filename) {
		ArrayList<String> s = new ArrayList<String>();
		try {
			BufferedReader br = null;
			File f = new File(filename);
			br = new BufferedReader(new FileReader(f));
			String line = null;
			while ((line = br.readLine()) != null) {
				s.add(line);
			}
		} catch (IOException ex) {
		}
		return s;
	}
}
